<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">微信公众号客服消息</ui:define>
    <ui:define name="content">
        <h:form>
        
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="left">
                        <p:commandButton id="toggler" type="button" value="展示选择"
                                         style="width: auto;"
                                         icon="ui-icon-calculator"
                                         rendered="#{security:areAllGranted('WECHAT_CUSTOMER_MESSAGE_SEARCH')}"/>
                        <p:columnToggler datasource="wechatCustomerMessageDataTable" trigger="toggler"
                                         rendered="#{security:areAllGranted('WECHAT_CUSTOMER_MESSAGE_SEARCH')}"/>
                    </f:facet>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{wechatCustomerMessageBean.isNormal() and security:areAllGranted('WECHAT_CUSTOMER_MESSAGE_SEARCH')}"/>

                        <p:commandButton icon="fa fa-plus" value="新增客服消息"
                                         action="#{wechatCustomerMessageBean.onAdd}"
                                         rendered="#{wechatCustomerMessageBean.isNormal() and security:areAllGranted('WECHAT_CUSTOMER_MESSAGE_ADD')}">
                            <f:setPropertyActionListener value="/views/wechat/wechat-customer-message.xhtml"
                                                         target="#{currentUserBean.back}"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="8" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-2"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">

                                <p:outputLabel for="name" value="消息名"/>
                                <p:inputText id="name" value="#{wechatCustomerMessageBean.$.name}" style="width:100%"/>

                                <p:outputLabel for="msgType" value="消息类型"/>
                                <p:selectOneMenu id="msgType" value="#{wechatCustomerMessageBean.$.msgType}"
                                                 filter="true" filterMatchMode="contains">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{wechatCustomerMessageBean.dictionaries[DictionaryCode.WECHAT_CUSTOMER_MESSAGE_MSG_TYPE]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>

                                </p:selectOneMenu>


                                <p:outputLabel for="status" value="消息状态"/>
                                <p:selectOneMenu id="status" value="#{wechatCustomerMessageBean.$.status}"
                                                 filter="true" filterMatchMode="contains">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{wechatCustomerMessageBean.dictionaries[DictionaryCode.WECHAT_CUSTOMER_MESSAGEA_STATUS]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>

                                </p:selectOneMenu>

                   				<p:outputLabel for="productId" value="公众号"/>
                                <p:selectOneMenu id="productId" value="#{wechatCustomerMessageBean.$.productId}"
                                				 filter="true" filterMatchMode="contains">
                                     <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                                   	 <f:selectItems
                                            value="#{wechatCustomerMessageBean.dictionaries[DictionaryCode.WECHAT_OFFICIAL_ACCOUNT]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="id" value="消息ID"/>
                                <p:inputNumber id="id" value="#{wechatCustomerMessageBean.$.id}" style="width:100%"/>

                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="wechatCustomerMessageDataTable"
                                         style="width: 100%"
                                         var="record"
                                         value="#{wechatCustomerMessageBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         selection="#{wechatCustomerMessageBean.selectedRecords}"
                                         resizableColumns="true"
                                         rendered="#{security:areAllGranted('WECHAT_CUSTOMER_MESSAGE_SEARCH')}">

                                <p:column headerText="操作" rendered="#{wechatCustomerMessageBean.isNotBatch()}">
                                    <p:splitButton icon="fa fa-eye" action="#{wechatCustomerMessageBean.onViewWechatCustomerMessage(record.id)}"
                                                   process="@this">
                                        <f:setPropertyActionListener value="/views/wechat/wechat-customer-message.xhtml"
                                                                     target="#{currentUserBean.back}"/>

                                        <p:menuitem value="上线" icon="fa fa-arrow-up"
                                                    action="#{wechatCustomerMessageBean.onLine(record.id)}"
                                                    process="@this" update="@form"
                                                    rendered="#{record.showOnlineBottom()}"/>

                                        <p:menuitem value="下线" icon="fa fa-arrow-down"
                                                    action="#{wechatCustomerMessageBean.offLine(record.id)}"
                                                    process="@this" update="@form"
                                                    rendered="#{record.showOfflineBottom()}"/>

                                    </p:splitButton>
                                </p:column>

                                <p:column headerText="消息ID">
                                    <h:outputText value="#{record.id}"/>
                                </p:column>

                                <p:column headerText="消息名">
                                    <h:outputText value="#{record.name}"/>
                                </p:column>

                                <p:column headerText="消息类型">
                                    <h:outputText value="#{wechatCustomerMessageBean.translate(DictionaryCode.WECHAT_CUSTOMER_MESSAGE_MSG_TYPE, record.msgType)}"/>
                                </p:column>

                                <p:column headerText="有效期开始时间">
                                    <h:outputText value="#{record.effectiveStartTime}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>

                                <p:column headerText="有效期结束时间">
                                    <h:outputText value="#{record.effectiveEndTime}">
                                        <f:convertDateTime pattern="#{constants:get('DATETIME_FORMAT')}"/>
                                    </h:outputText>
                                </p:column>

                                <p:column headerText="公众号">
                                    <h:outputText value="#{wechatCustomerMessageBean.translate(DictionaryCode.WECHAT_OFFICIAL_ACCOUNT, record.productId)}"/>
                                </p:column>
                                <p:column headerText="状态">
                                    <h:outputText value="#{wechatCustomerMessageBean.translate(DictionaryCode.WECHAT_CUSTOMER_MESSAGEA_STATUS, record.status)}"/>
                                </p:column>
                                <p:column headerText="操作人">
                                    <h:outputText value="#{record.updator}"/>
                                </p:column>
                                
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
